.PHONY: help install dev build docker-build docker-run docker-stop clean test

help:
	@echo "人脸质量检测API - 命令帮助"
	@echo ""
	@echo "可用命令:"
	@echo "  make install       - 安装依赖"
	@echo "  make dev          - 启动开发服务器"
	@echo "  make build-rust   - 编译Rust扩展"
	@echo "  make docker-build - 构建Docker镜像"
	@echo "  make docker-run   - 运行Docker容器"
	@echo "  make docker-stop  - 停止Docker容器"
	@echo "  make clean        - 清理临时文件"
	@echo "  make test         - 运行测试"

install:
	@echo "📦 安装依赖..."
	pip install -r requirements.txt
	@echo "✅ 依赖安装完成"

dev:
	@echo "🚀 启动开发服务器..."
	uvicorn api:app --host 0.0.0.0 --port 8000 --reload

build-rust:
	@echo "🦀 编译Rust扩展..."
	cd rust_extension && bash build.sh
	@echo "✅ Rust扩展编译完成"

docker-build:
	@echo "🐳 构建Docker镜像..."
	docker-compose build
	@echo "✅ Docker镜像构建完成"

docker-run:
	@echo "🐳 启动Docker容器..."
	docker-compose up -d
	@echo "✅ 服务已启动: http://localhost:8000"

docker-stop:
	@echo "🛑 停止Docker容器..."
	docker-compose down
	@echo "✅ 容器已停止"

docker-logs:
	@echo "📋 查看日志..."
	docker-compose logs -f

clean:
	@echo "🧹 清理临时文件..."
	find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
	find . -type f -name "*.pyc" -delete 2>/dev/null || true
	find . -type f -name "*.pyo" -delete 2>/dev/null || true
	find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
	rm -rf build/ dist/ .pytest_cache/ 2>/dev/null || true
	@echo "✅ 清理完成"

test:
	@echo "🧪 运行测试..."
	pytest tests/ -v
	@echo "✅ 测试完成"

